﻿using BasehInfoManager_IDal;
using BasehInfoManagerModel;
using BasehInfoManagerViewModel;
using BasehInfoManagerViewModel.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using zy_11_10.Common.Lib.TexTools;

namespace BaseInfoManagerBll
{
  public   class AdminUserBll
    {

        //依赖注入
        private IAdminUserDal _iAdminUserDal;
        public AdminUserBll(IAdminUserDal iAdminUserDal)
        {
            _iAdminUserDal = iAdminUserDal;
        }


        //用户显示查询
        public PagerResult<AdminUser> SearchPage(SearchModel searchModel)
        {
            return _iAdminUserDal.SearchPage(searchModel);
        }

        //添加用户信息
        public bool AdminUserAdd(AdminUserView view)
        {
            //加密CMD5
            view.pass_word = StringMd5.Md5Hash32Salt(view.pass_word);
            return _iAdminUserDal.AdminUserAdd(view);
        }
        //反填用户表
        public AdminUser GetAdminUserByUserName(string userName)
        {
            return _iAdminUserDal.GetAdminUserByUserName(userName);
        }
        //用户模型表
        public AdminUserView GetAdminUserViewByUserName(string userName)
        {
            return _iAdminUserDal.GetAdminUserViewByUserName(userName);
        }

        //修改
        public bool AdminUserUpdate(AdminUserView view )
        {
            return _iAdminUserDal.AdminUserUpdate(view);
        }
        //查询用户名
        public bool VAdmminUserName(string userName)
        {
            if (GetAdminUserByUserName(userName) == null) return true;
            return false;
                 
        }

        //修改密码
        public int AdminUserPwdUpdate(string userName, string Npwd)
        {
            Npwd=StringMd5.Md5Hash32Salt(Npwd);
            return _iAdminUserDal.AdminUserPwdUpdate(userName, Npwd);
        }

    }
}
